import $api from "@/api/index.js"

export default {
	state: {
		//主题颜色
		configInfo: {
			id: 0,
			navBarHeight: uni.getSystemInfoSync().statusBarHeight * 1 + 44,
			isIos: uni.getSystemInfoSync().system.includes('iOS'),
			canIUseGetUserProfile: uni.getUserProfile ? true : false,
			primaryColor: '#39b54a',
			subColor: '#F3A664',
			refund_img: 'https://lbqny.migugu.com/paotui/errand.png',
			curSysHeight: '',
			tabbarHeight: '',
			expressList: [{
				id: 1,
				title: '同城配送'
			}, {
				id: 2,
				title: '中通快递'
			}, {
				id: 3,
				title: '圆通快递'
			}, {
				id: 4,
				title: '申通快递'
			}, {
				id: 5,
				title: '韵达快递'
			}]
		}
	},
	mutations: {
		updateConfigItem(state, item) {
			let {
				key,
				val
			} = item
			state[key] = val
		},
	},
	actions: {
		// 获取基本配置
		async getConfigInfo({
			commit,
			state
		}, param) {
			let config = await $api.base.configInfo()
			let data = Object.assign(state.configInfo, config)
			commit('updateConfigItem', {
				key: 'configInfo',
				val: data
			})
		},
	}
}
